<?php

namespace app\admin\controller;

use think\Lang;
use app\common\model\Goodsclass;
/**
 * ============================================================================
 * DSMall多用户商城
 * ============================================================================
 * 版权所有 2014-2028 长沙德尚网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.csdeshang.com
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * 控制器
 */
class Goodproject extends AdminControl {

    const EXPORT_SIZE = 1000;

    public function _initialize() {
        parent::_initialize();
        Lang::load(APP_PATH . 'admin/lang/'.config('default_lang').'/brand.lang.php');
    }

    #上传图片
    public function ajax_videos()
    {
        $old_name = $_FILES['file']['name'];
        $file_type = array('0' => 'gif', '1' => 'jpg', '2' => 'jpeg', '3' => 'png');
        $file_foot_name = substr($_FILES['file']['name'], (strripos($_FILES['file']['name'], ".")) + 1);
        if (!in_array($file_foot_name, $file_type)) {
            $data['msg'] = 1;
            return $data;
        }
        $upload_info = upload_qiniu('file');
        $data['msg'] = 1;
        $data['files_name'] = $upload_info['data'];
        $data['files_path'] = 'http://33wang.douyinhot.com' .'/'. $upload_info['data'] ;
        return $data;
    }

    #上传视频
    public function ajax_video()
    {
        $old_name = $_FILES['file']['name'];
        $file_type = array('0' => 'mov', '1' => 'mp4', '2' => 'wmv', '3' => 'avi');
        $file_foot_name = substr($_FILES['file']['name'], (strripos($_FILES['file']['name'], ".")) + 1);
        if (!in_array($file_foot_name, $file_type)) {
            $data['msg'] = 1;
            return $data;
        }
        $upload_info = upload_qiniu('file');
        $data['msg'] = 1;
        $data['files_name'] = $upload_info['data'];
        return $data;
    }
    /**
     * 项目定制列表
     */
    public function index() {
        $brand_model = model('goodproject');
        
        /**
         * 检索条件
         */
        if (!empty(input('param.search_brand_name'))) {
            $condition['project_title'] = array('like', "%" . input('param.search_brand_name') . "%");
        }
        $condition['project_sort'] = '0';
        $goods_project_class = input('param.project_class', '');

        if (!empty($goods_project_class)) {
            $condition['project_class'] = intval($goods_project_class);
        }

        $brand_list = $brand_model->getBrandList($condition, "*", 10);
        foreach ($brand_list as $key => $value) {
            $brand_list[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']);
        }
        $this->assign('showpage', $brand_model->page_info->render());
        $this->assign('brand_list', $brand_list);
        $this->assign('search_brand_name', trim(input('param.search_brand_name')));

        //项目定制分类
        $project_class = db('goodsproject_class')->where(['status'=>1])->select();
        $this->assign('project_class', $project_class);
        $this->assign('goods_project_class', $goods_project_class);
        $this->setAdminCurItem('index');
        return $this->fetch();
    }
    #上下架
    public function status()
    {
        $id = input('param.project_id');

        $goods_info = db('goodsproject')->where('project_id', $id)->find();
        if (empty($goods_info)) {
            ds_json_encode(10001, '操作失败');
        }
        if ($goods_info['status'] == 1) {
            #下架操作
            $status = 0;
        } else {
            #上架操作
            $status = 1;
        }

        $return = db('goodsproject')->where('project_id', $id)->data(['status' => $status])->update();
        if ($return) {
            // 添加操作日志
            $this->log('商品上下架commonid' . $id, 1);
            ds_json_encode(10000, '操作成功');
        } else {
            $this->log('商品上下架commonid' . $id, 0);
            ds_json_encode(10001, '操作失败');
        }

    }

    /**
     * 增加项目定制
     */
    public function add() {
        $brand_model = model('goodproject');
        if (request()->isPost()) {
                // $conyent = json_encode(input('post.article_content'));
                $conyent = input('post.article_content');

                $data = [
                    'project_title' => input('post.project_title'),
                ];   
                $brand_validate = validate('Goodproject');
//                $express_list = rkcache('area', true);
//                $insert_array['goods_commonid'] = $express_list;
                $insert_array['project_title'] = input('post.project_title');
                $insert_array['project_describe'] = $conyent;
                $insert_array['project_images'] = input('post.videos');
                $insert_array['status'] = input('post.status');
                $insert_array['create_time'] = time();
                $insert_array['project_class'] = input('post.project_class');
                $insert_array['total_price'] = input('post.total_price');
                $insert_array['fee_price'] = input('post.fee_price');
                $insert_array['charge_price'] = input('post.charge_price');
                $insert_array['plementation_price'] = input('post.plementation_price');
                $insert_array['science'] = input('post.science');
                
                #视频
                $insert_array['project_videos'] = input('post.videoss');
                $insert_array['default_images'] = input('post.default_images');

                $result = $brand_model->addBrand($insert_array);
//                dkcache('area');
                if ($result) {
                    $this->log(lang('ds_add') . lang('brand_index_brand') . '[' . input('post.brand_name') . ']', 1);
                    $this->success('添加成功', url('Goodproject/index'));
                } else {
                    $this->error(lang('ds_common_save_fail'));
                }

        } else {
            $brand_model = model('goodproject');

            if (!empty(input('param.search_brand_name'))) {
                $condition['project_title'] = array('like', "%" . input('param.search_brand_name') . "%");
            }

            $this->assign('search_brand_name', trim(input('param.search_brand_name')));
            $this->setAdminCurItem('add');

            $brand_array = [
                'project_id' => '',
                'project_title' => '',
                'project_images' => '',
                'project_describe' => '',
                'status' => 1,
                'project_class' => '',
                'total_price' => '',
                'fee_price' => '',
                'charge_price' => '',
                'plementation_price' => '',
                'science' => '',
                'project_videos' => '',
                'default_images' => ''
            ];
            $this->assign('brand_array', $brand_array);
            //查询已经审核完成的商品
            $condition['goods_state'] = '1';
            $condition['goods_verify'] = '1';
            $condition['goods_lock'] = '0';
            $condition['goods_status'] = '1';
            $goods = db('goodscommon')->where($condition)->select();
            foreach($goods as $key => $val){
                $goods[$key]['goods_name'] = $val['goods_name'];
                $goods[$key]['goods_commonid'] = $val['goods_commonid'];
            }
            $this->assign('goods_info', $goods);

            //项目定制分类
            $project_class = db('goodsproject_class')->where(['status'=>1])->select();
            $this->assign('project_class', $project_class);

            return $this->fetch('add');
        }
    }
    //数据入库
    public function ins() {

        $brand_model = model('goodproject');
        $data = [
            'project_title' => input('post.project_title'),
        ];
        $brand_validate = validate('Goodproject');
        if (!$brand_validate->scene('brand_add')->check($data)) {
            $this->error($brand_validate->getError());
        } else {
            $insert_array = array();
            //上传图片
            $default_dir = BASE_UPLOAD_PATH . DS . ATTACH_PATH . '/membertag';
            $img='';
            if (!empty($_FILES['project_images']['name'])) {
                $file = request()->file('project_images');
                $info = $file->rule('uniqid')->validate(['ext' =>ALLOW_IMG_EXT])->move($default_dir);
                if ($info) {
                    $img = $info->getFilename();
                }else {
                    $this->error($file->getError());
                }
            }
//                $express_list = rkcache('area', true);
//                $insert_array['goods_commonid'] = $express_list;
            $insert_array['project_title'] = input('post.project_title');
            $insert_array['project_describe'] = input('post.project_describe');
            $insert_array['project_images'] = $img;
            $insert_array['status'] = input('post.status');
            $insert_array['create_time'] = time();

            $result = $brand_model->addBrand($insert_array);
//                dkcache('area');
            return json(['url' => url('Goodproject/index'), 'code' => 1, 'msg' => '添加成功']);
        }

    }
    /**
     * 列表编辑
     */
    public function projec_edit() {
        $brand_model = model('goodproject');

        if (request()->isPost()) {
            $data = [
                'project_title' => input('post.project_title'),
            ];
            $brand_validate = validate('Goodproject');
            if (!$brand_validate->scene('brand_add')->check($data)) {
                $this->error($brand_validate->getError());
            } else {
                $condition['project_id'] = input('post.project_id');
                $update_array['project_images'] = input('post.videos');
                $update_array['project_videos'] = input('post.videoss');
                $update_array['default_images'] = input('post.default_images');

                $img = db('goodsproject')->where(['project_id'=>$condition['project_id']])->find();
                if(empty($update_array['project_images'])){
                    $update_array['project_images'] = $img['project_images'];
                }

                if(empty($update_array['project_videos'])){
                    $update_array['project_videos'] = $img['project_videos'];
                }
                
                if(empty($update_array['default_images'])){
                    $update_array['default_images'] = $img['default_images'];
                }

                $brand_info = $brand_model->getBrandInfo(array('project_id' => intval(input('post.project_id'))));
                  
                $conyent = input('post.article_content');

                $express_list = rkcache('goods', true);
                $update_array['goods_commonid'] = empty($express_list) ? $brand_info['goods_commonid'] : $express_list ;
                $update_array['project_title'] = input('post.project_title');
                $update_array['project_describe'] = $conyent;

                $update_array['status'] = input('post.status');
                $update_array['project_class'] = input('post.project_class');
                $update_array['total_price'] = input('post.total_price');
                $update_array['fee_price'] = input('post.fee_price');
                $update_array['charge_price'] = input('post.charge_price');
                $update_array['plementation_price'] = input('post.plementation_price');
                $update_array['science'] = input('post.science');

                $result = $brand_model->editBrand($condition,$update_array);
                dkcache('goods');
                if ($result) {
                    $this->log(lang('ds_add') . lang('brand_index_brand') . '[' . input('post.brand_name') . ']', 1);
                    $this->success('修改成功', url('Goodproject/index'));
                } else {
                    $this->error(lang('ds_common_save_fail'));
                }
            }

        } else {
            $brand_model = model('goodproject');

            $brand_info = $brand_model->getBrandInfo(array('project_id' => intval(input('param.project_id'))));

            $brand_info['video_type'] = empty($brand_info['project_videos']) ? '' : $brand_info['project_videos'];
            $brand_info['default_images'] = empty($brand_info['default_images']) ? '' : $brand_info['default_images'];

            if (empty($brand_info)) {
                $this->error(lang('param_error'));
            }
            $this->assign('edit_goods_sign', true);
            $this->assign('brand_array', $brand_info);

          

            //项目定制分类
            $project_class = db('goodsproject_class')->where(['status'=>1])->select();
            $this->assign('project_class', $project_class);

            $config = db('config')->where('code', 'qiniu_http')->find();
            $this->assign('http_name', $config['value']);
            $this->setAdminCurItem('add');
            return $this->fetch('add');
        }
    }

    //商品管理
    public function projec_goods(){
        $brand_model = model('goodproject');

        if (request()->isPost()) {
            $data = [
                'project_title' => input('post.project_title'),
            ];
            $brand_validate = validate('Goodproject');
            if (!$brand_validate->scene('brand_add')->check($data)) {
                $this->error($brand_validate->getError());
            } else {
                $update_array = array();
                //上传图片
                $default_dir = BASE_UPLOAD_PATH . DS . ATTACH_PATH . '/membertag';
                $img='';
                if (!empty($_FILES['project_images']['name'])) {
                    $file = request()->file('project_images');
                    $info = $file->rule('uniqid')->validate(['ext' =>ALLOW_IMG_EXT])->move($default_dir);
                    if ($info) {
                        $img = $info->getFilename();
                    }else {
                        $this->error($file->getError());
                    }
                }

                $brand_info = $brand_model->getBrandInfo(array('project_id' => intval(input('post.project_id'))));

                $condition['project_id'] = input('post.project_id');
                $express_list = rkcache('goods', true);
                $update_array['goods_commonid'] = empty($express_list) ? $brand_info['goods_commonid'] : $express_list ;
                $update_array['project_title'] = input('post.project_title');
                $update_array['project_describe'] = input('post.project_describe');
                $update_array['project_images'] = empty($img) ? $brand_info['project_images'] : $img ;
                $update_array['status'] = input('post.status');
                $result = $brand_model->editBrand($condition,$update_array);
                dkcache('goods');
                if ($result) {
                    $this->log(lang('ds_add') . lang('brand_index_brand') . '[' . input('post.brand_name') . ']', 1);
                    $this->success('修改成功', url('Goodproject/index'));
                } else {
                    $this->error(lang('ds_common_save_fail'));
                }
            }
        } else {

            //项目定制标题id
            $project_id = input('param.project_id');

            $this->assign('project_id', $project_id);

            $goods = db('goodsproject')->where(['project_id'=>$project_id])->find();
            $search_goods_name = trim(input('param.search_goods_name'));
            $store_name = trim(input('param.store_name'));

            if($goods['goods_commonid']){
                //数量
                // $this->assign('num', $goods['num']);
                //标题
                $this->assign('title', $goods['project_title']);
                //搜索条件
                $this->assign('search_brand_name', trim(input('param.search_brand_name')));

                //所有绑定商品的id
                $goods_info = explode(",", $goods['goods_commonid']);

                $goods_model = model('goods');
                /**
                 * 处理商品分类
                 */
                $choose_gcid = ($t = intval(input('param.choose_gcid'))) > 0 ? $t : 0;
                $gccache_arr = model('goodsclass')->getGoodsclassCache($choose_gcid, 3);
                $this->assign('gc_json', json_encode($gccache_arr['showclass']));
                $this->assign('gc_choose_json', json_encode($gccache_arr['choose_gcid']));
                /**
                 * 查询条件
                 */
                $where = array();
                //根据选中的id

                if (!empty($goods['goods_commonid'])) {
                    // $where['goodscommon.goods_commonid'] = ['in',$goods_info];
                    $where['goodscommon.goods_id'] = ['in',$goods_info];
                }
                
                $where = [
                    'goodsprojectnums.project_id' => $project_id
                ];
                //关键词
                
                if ($search_goods_name != '') {
                    $where['goods_name'] = array('like', '%' . $search_goods_name . '%');
                }
               //.供应商名称
                
                if ($store_name != '') {
                    $where['store_name'] = array('like', '%' . $store_name . '%');
                }

                //品牌
                $b_id = intval(input('param.b_id'));
                if ($b_id > 0) {
                    $where['brand_id'] = $b_id;
                }
                //分类
                if ($choose_gcid > 0) {
                    $where['gc_id_' . ($gccache_arr['showclass'][$choose_gcid]['depth'])] = $choose_gcid;
                }

                $goods_list = $goods_model->getGoodsCommonProject($where, '*', 10, '');
                $goods_list = getClassName($goods_list);
                foreach ($goods_list as $key => $value) {
                    $brand_info = db('brand')->where(['brand_id'=>$value['brand_id']])->find();
                    $goods_list[$key]['brand_name'] = $brand_info['brand_name'];
                }
                $this->assign('goods_list', $goods_list);

                

                $this->assign('show_page', $goods_model->page_info->render());

                $storage_array = $goods_model->calculateStorage($goods_list);
                $this->assign('storage_array', $storage_array);

                // 品牌
                $brand_list = model('brand')->getBrandPassedList(array());

                $this->assign('search', $where);
                $this->assign('brand_list', $brand_list);
            }else{
                $goods_list[] = [
                    'project_id' => '',
                    'project_title' => '',
                    'project_images' => '',
                    'project_describe' => '',
                    'goods_name' => '',
                    'status' => 1,
                ];
                $this->assign('title', $goods['project_title']);
                $this->assign('goods_list', $goods_list);
            }

            //商品列表
            $this->assign('search_goods_name', $search_goods_name);
            $this->assign('store_name', $store_name);
            $this->setAdminCurItem('projec_goods');
            return $this->fetch('projec_goods');
        }
    }
    /**
     * 详细页
     */
    public function detail() {
        $brand_model = model('goodproject');
        $brand_info = $brand_model->getBrandInfo(array('project_id' => intval(input('param.project_id'))));

        $name = db('goodsproject_class')->where(['id'=>$brand_info['project_class']])->find();
        $this->assign('name',$name['name']);
        if (empty($brand_info)) {
            $this->error(lang('param_error'));
        }
        $this->assign('brand_array', $brand_info);

        $config = db('config')->where('code', 'qiniu_http')->find();
        $this->assign('http_name', $config['value']);

        return $this->fetch('detail');
    }
    /*
      选择绑定商品
     */
    public function band_goods() {

        $brand_model = model('goodproject');
        if (request()->isPost()) {
            $data = input('post.goods_commonid/a');

            foreach ($data as $key => $value) {
                $info[] = $value;
            }
            $goods = implode(",", $info);
            wkcache('area', $goods);
            dsLayerOpenSuccess('添加成功');
        } else {
            if (!empty(input('param.search_brand_name'))) {
                $condition['goods_name'] = array('like', "%" . input('param.search_brand_name') . "%");
            }
            $this->assign('search_brand_name', trim(input('param.search_brand_name')));
            //查询已经审核完成的商品
            $condition['goods_state'] = '1';
            $condition['goods_verify'] = '1';
            $condition['goods_lock'] = '0';
            $condition['goods_status'] = '1';
            $goods = db('goodscommon')->where($condition)->select();
            foreach($goods as $key => $val){
                $goods_info[$key]['goods_name'] = $val['goods_name'];
                $goods_info[$key]['goods_commonid'] = $val['goods_commonid'];
                $goods_info[$key]['goods_advword'] = $val['goods_advword'];
            }
            $this->assign('goods_info', $goods_info);

            return $this->fetch();
        }
    }
//编辑数量
    public function num(){

        if (request()->isPost()) {
            $brand_model = model('goodproject');
            $data = input('param.');
            if($data['num'] < 1){
                dsLayerOpenSuccess('请输入正确数量');
            }
            $result = db('goodsprojectnums')->where(['project_id'=>$data['project_id'],'goods_commonid'=>$data['goods_id']])->update(['num'=>$data['num']]);
            $goods_result = db('goodscommon')->where(['goods_commonid'=>$data['goods_id']])->update(['num'=>$data['num']]);
            if ($goods_result) {
                dsLayerOpenSuccess('编辑成功');
            }
        }else{
            $brand_model = model('goodproject');
            $brand_info = $brand_model->getBrandInfo(array('project_id' => intval(input('param.project_id'))));
            if (empty($brand_info)) {
                $this->error(lang('param_error'));
            }
            $this->assign('brand_array', $brand_info);

            $project_id = input('param.project_id');
            $this->assign('project_id', $project_id);

            $goods_id = input('param.goods_id');
            $this->assign('goods_id', $goods_id);

            $result = db('goodsprojectnums')->where(['project_id'=>$project_id,'goods_commonid'=>$goods_id])->find();
            $this->assign('num', $result['num']);


            return $this->fetch();
        }

    }

    //删除商品
    public function goods_drop(){
        $project_id = input('param.project_id');
        $goods_id = input('param.goods_id');
        //判断这个id在不在绑定商品里面
        $goods = db('goodsproject')->where(['project_id'=>$project_id])->find();

        $goods_info = explode(",", $goods['goods_commonid']);

        foreach ($goods_info as $key=>$value)
        {
            if ($value === $goods_id){
                unset($goods_info[$key]);
            }
        }
        $id = implode(",",$goods_info);

        $result = db('goodsproject')->where(['project_id'=>$project_id])->update(['goods_commonid'=>$id ]);
        $num = db('goodsprojectnums')->where(['goods_commonid'=>$goods_id,'project_id'=>$project_id])->delete();

        ds_json_encode(10000, lang('ds_common_del_succ'));




    }
    /*
     修改绑定商品
    */
    public function edit_band_goods() {
        $goods_model = model('goods');
        $brand_model = model('goodproject');
        if (request()->isPost()) {
            $data = input('post.goods_commonid/a'); #goods_id
            if(!empty($data)){
                $project_id =  input('post.project_id');
                foreach ($data as $key => $value) {
                    $info[] = $value;
                }
                $goods = implode(",", $info);

                $goodsproject_info = db('goodsproject')->where(['project_id'=>$project_id])->find();

                if($goodsproject_info['goods_commonid']){ 
                    $goods_ids_array = explode(',',$goodsproject_info['goods_commonid']);
                    $new_array = array_merge($goods_ids_array,$data);
                    $goods = implode(",", $new_array);
                }
                $result = db('goodsproject')->where(['project_id'=>$project_id])->update(['goods_commonid'=>$goods]);
                //判断库里是否有数据
                foreach ($data as $k=>$v){
                    $result = db('goodsprojectnums')->where(['goods_commonid'=>$v,'project_id'=>$project_id])->find();
                    if(!$result){
                        $res = [
                            'goods_commonid' => $v,
                            'goods_id' => $v,
                            'project_id' => $project_id,
                            'num' => 1,
                            'create_time' => time()
                        ];
                        $num = db('goodsprojectnums')->insertGetId($res);
                    }
                }
                dsLayerOpenSuccess('导入成功');
            }else{
                dsLayerOpenSuccess('请选择需要导入的商品');
            }

        } else {
            $goods_model = model('goods');

            $project_id = input('param.project_id');

            $where['project_id'] = $project_id;
            $info = db('goodsproject')->where($where)->find();
            $this->assign('project_id', $project_id);

            $info = explode(',',$info['goods_commonid']);
            $this->assign('info', $info);

            if (!empty(input('param.search_brand_name'))) {
                $condition['goods_name'] = array('like', "%" . input('param.search_brand_name') . "%");
            }
            $this->assign('search_brand_name', trim(input('param.search_brand_name')));


            // ------------------------
            $goods_model = model('goods');
            /**
             * 处理商品分类
             */
            $choose_gcid = ($t = intval(input('param.choose_gcid'))) > 0 ? $t : 0;

            $gccache_arr = model('goodsclass')->getGoodsclassCache($choose_gcid, 3);
            $this->assign('gc_json', json_encode($gccache_arr['showclass']));
            $this->assign('gc_choose_json', json_encode($gccache_arr['choose_gcid']));
            /**
             * 查询条件
             */
            $where = array();

            $where['goods_lock'] = '0';
            $where['goods_status'] = '1';
            $where['goodscommon.is_two_goods'] = '0';
            //邹建伟
            // $where['goods_commonid'] = ['not in',$info];
            $where['goods.goods_id'] = ['not in',$info];
            //关键词
            $search_goods_name = trim(input('param.search_goods_name'));
            if ($search_goods_name != '') {
                $where['goodscommon.goods_name'] = array('like', '%' . $search_goods_name . '%');
            }
            //供应商
            $store_name = trim(input('param.store_name'));
            if ($store_name != '') {
                $where['goodscommon.store_name'] = array('like', '%' . $store_name . '%');
            }
            //分类查询
            $search_gc_id1 = input('get.search_gc_id1', '');
            $search_gc_id2 = input('get.search_gc_id2', '');
            $search_gc_id3 = input('get.search_gc_id3', '');
            if ($search_gc_id1) {
                $where['goodscommon.gc_id_1'] = ['eq', $search_gc_id1];
            }
            if ($search_gc_id2) {
                $where['goodscommon.gc_id_2'] = ['eq', $search_gc_id2];
            }
            if ($search_gc_id3) {
                $where['goodscommon.gc_id_3'] = ['eq', $search_gc_id3];
            }

            //品牌
            $b_id = intval(input('param.b_id'));
            if ($b_id > 0) {
                $where['brand_id'] = $b_id;
            }

            // $goods_list = $goods_model->getGoodsCommonList($where, '*', 10, 'goods_commonid desc'); 第一
            // $goods_list = $goods_model->getGoodsProjectLists($where, '*', '','',10); 第二（最新）
            $goods_list = $goods_model->getGoodsUnionListss($where, '*,goods.goods_name as new_goods_name', 'goodscommon.goods_addtime desc');

            $this->assign('goods_list', $goods_list);
            $this->assign('search_goods_name', $search_goods_name);
            $this->assign('store_name', $store_name);
            $this->assign('choose_gcid', $choose_gcid);
            $this->assign('show_page', $goods_model->page_info->render());

            $storage_array = $goods_model->calculateStorage($goods_list);
            $this->assign('storage_array', $storage_array);

            // 品牌
            $brand_list = model('brand')->getBrandPassedList(array());

            $this->assign('search', $where);
            $this->assign('brand_list', $brand_list);

            //三级分类查询
            $class = new Goodsclass();
            $parent_class_list = $class->getGoodsclassList(['gc_parent_id'=>0]);
            $this->assign('class_list',$parent_class_list);
            return $this->fetch();
        }
    }

    /**
     * 删除项目定制
     */
    public function projec_del() {
        $project_id = input('param.project_id');
        $brand_mod = model('goodproject');
        $brand_mod->delBrand(array('project_id' => $project_id));
        $this->log(lang('ds_del') . lang('brand_index_brand') . '[ID:' . $project_id . ']', 1);
        ds_json_encode(10000, lang('ds_common_del_succ'));
    }
    /**
     * 获取卖家栏目列表,针对控制器下的栏目
     */
    protected function getAdminItemList() {
        $menu_array = array(
            array(
                'name' => 'index',
                'text' => '定制列表',
                'url' =>  url('Goodproject/index'),
            ),
            array(
                'name' => 'add',
                'text' => '添加',
                'url' => url('Goodproject/add')
            ),
        );
        if (request()->action() == 'projec_edit') {
            $menu_array[] = array(
                'name' => 'add',
                'text' => lang('ds_edit'),
                'url' => url('Goodproject/projec_edit')
            );
            unset($menu_array[1]);
        }
        // $menu_array[] = array(
        //        'name' => 'projec_goods',
        //        'text' => '商品管理',
        //        'url' => url('Goodproject/projec_goods')
        //    );
        return $menu_array;
    }

}